﻿<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>发送邮件</title>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/cookie.js" type="text/javascript"></script>
<script type="text/javascript">
        function startUpload() {
             document.getElementById('processing').innerHTML = '上传中...';
            return true;
        }
        function stopUpload(rel){
			//alert(rel);
            var msg;
            switch (rel) {
                case 0:
                    msg = "上传成功";
                    break;
				case 1:
					msg="上传文件失败，不支持的文件类型";
					 break;
				case 3:
					msg="文件过大";
					break;
                default:
                    msg = "上传文件失败";
            }   
            document.getElementById('processing').innerHTML = msg;
        }
    </script>
	<script type="text/javascript">
		function send(){
			document.getElementById('emailProcessing').innerHTML = '发送中...';
			var fileName=getCookie('fileName');
			var receiver=document.getElementById('receiver').value;
			var body=document.getElementById('body').value;
			var subject=document.getElementById('subject').value;
			//alert("fileName:"+fileName+"@receiver:"+receiver+"@subject:"+subject+"@body:"+body);
			 $.ajax({
				type:"POST", // 也可以改成 POST
				async:false, //
				cache:false, //
				url:"myMail.php",
				data:{rec:receiver,fName:fileName,sub:subject,body:body},   
				success:function(msg)// msg是receive.php返回的信息
				{     // 如果提交成功可以在这进行一些后续操作  

					if(msg[0]==1){
							alert("发送成功");
							 location.reload();
							document.getElementById('emailProcessing').innerHTML = '';
						
					}else{
							document.getElementById('emailProcessing').innerHTML = '发送失败';
							
					}
				}   
			 }); 
		}
	</script>
</head>
<body>
	<label for="receiver" >收件人:</label><input id="receiver" type="text" width="300px" height="200px"/>
	<br/>
	
	<br/><br/>
	
	<label>上传文件（大小小于5M）：</label>
       
        <form action="upload_file.php" method="post" enctype="multipart/form-data" target="form-target" onsubmit="startUpload();">
            <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
            <input type="file" name="myfile" />
            <input type="submit" name="sub" value="upload" />
        </form>
		
        <iframe style="width:0; height:0; border:0;" name="form-target"></iframe>
		 <div id="processing"></div>
		<br/>
		 <label for="subject" >主题:</label>
        <textarea id="subject" name="subject" rows="1" cols="30"></textarea>
		<br/>
        <label for="body" >正文:</label><br/>
        <textarea id="body" name="body" rows="10" cols="30"></textarea>

	   <input type="button" name="send" value="send" onClick="send()"/>
	   <br/>
	   <div id="emailProcessing"></div>
	

</body>
</html>